/*
 * To change this template, choose Tools | Templates
 * and opem the template in the editor.
 */
package com.mycompany.pagoxusuario.controllers;

import com.mycompany.pagoxusuario.entidades.TributoMulta;
import com.mycompany.pagoxusuario.persistence.JPAUtil;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.persistence.EntityManager;

/**
 *
 * @author josediaz
 */
@ManagedBean
@ViewScoped
public class TributoMultaBean {

    private TributoMulta tributo;
    private TributoMulta multa;
    private List<TributoMulta> tributos;
    private List<TributoMulta> multas;
    private boolean continuarInsercion;

    @PostConstruct
    public void init() {
        tributo = new TributoMulta();
        multa = new TributoMulta();
    }

    public void grabarTributo() {
        EntityManager em = JPAUtil.getEntityManager();
        em.persist(tributo);
    }
        
      public void grabarMulta() {
        EntityManager em = JPAUtil.getEntityManager();
        em.persist(multa);
    }
            
     public List<TributoMulta> getTributoMulta() {
      if (tributos == null) {
        tributos = JPAUtil.getEntityManager().createQuery("select m from TributoMulta m", TributoMulta.class).getResultList();
        return tributos;
        
      } else {
      if (multas == null){
            multas = JPAUtil.getEntityManager().createQuery("select m from TributoMulta m", TributoMulta.class).getResultList();
                }
                return multas;
            }
         }


    public TributoMulta getTributo() {
        return tributo;
    }

    public void setTributo(TributoMulta tributo) {
        this.tributo = tributo;
    }

    public TributoMulta getMulta() {
        return multa;
    }

    public void setMulta(TributoMulta multa) {
        this.multa = multa;
    }

    public List<TributoMulta> getTributos() {
        return tributos;
    }

    public void setTributos(List<TributoMulta> tributos) {
        this.tributos = tributos;
    }

    public List<TributoMulta> getMultas() {
        return multas;
    }

    public void setMultas(List<TributoMulta> multas) {
        this.multas = multas;
    }

    public boolean isContinuarInsercion() {
        return continuarInsercion;
    }

    public void setContinuarInsercion(boolean continuarInsercion) {
        this.continuarInsercion = continuarInsercion;
    }
    
    
  
}
